#include "header.h"

#define STYLE '#'
#define N 101

void process_v1()
{
	char buffer[N];
	memset(buffer, 0, sizeof(buffer));
	const char lable[] = "-\\|/";
	size_t len = strlen(lable);

	for (int cnt = 0; cnt <= 100;)
	{
		printf("\r[%-100s][%3d\%%][%c]", buffer, cnt, lable[cnt%len]);
		fflush(stdout);
		buffer[cnt++] = STYLE;
		usleep(5000);
	}
	putchar('\n');
}

void FlushProcess(double total, double cur)
{
	char buffer[N];
	memset(buffer, 0, sizeof(buffer));	
	const char lable[] = "-\\|/";
	size_t len = strlen(lable);
	double percent = cur/total;
	int num = percent*100;
	static int cnt = 0;

	for (int i = 0; i < num; ++i)
	{
		buffer[i] = STYLE;
	}

	printf("\r[%-100s][%6.2lf\%%][%c]", buffer, percent*100, lable[cnt%len]);
	fflush(stdout);
	++cnt;
}
